//
//  MujiDubProgressView.m
//  testdemo
//
//  Created by yule on 2017/5/23.
//  Copyright © 2017年 yule. All rights reserved.
//

#import "MujiDubProgressView.h"

@interface MujiDubProgressView ()

@property (nonatomic, strong) UIView   *trackView;
@property (nonatomic, strong) UIView   *progressView;



@end

@implementation MujiDubProgressView

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.frame = frame;
        
        //[self createUI];
        
        self.trackView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
        //self.trackView.backgroundColor = [UIColor colorWithRed:242/255.0f green:242/255.0f blue:242/255.0f alpha:1.0f];
        [self addSubview:self.trackView];

        self.progressView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, frame.size.height)];
        //self.progrssView.backgroundColor = [UIColor colorWithRed:242/255.0f green:242/255.0f blue:242/255.0f alpha:1.0f];
        [self addSubview:self.progressView];

        
    }
    
    return self;
}

- (void)setTrackHeight:(CGFloat)trackHeight
{
    [self.trackView setFrame:CGRectMake(0, 0, self.frame.size.width, trackHeight)];
}
- (void)setProgressHeight:(CGFloat)progressHeight
{
    [self.progressView setFrame:CGRectMake(0, (self.frame.size.height - progressHeight)/2, 0, progressHeight)];

    //NSLog(@"%@", NSStringFromCGRect(self.progressView.frame));
}
- (void)setTrackTintColor:(UIColor *)trackTintColor
{
    self.trackView.backgroundColor = trackTintColor;
}
- (void)setProgressTintColor:(UIColor *)progressTintColor
{
    self.progressView.backgroundColor = progressTintColor;

}

- (void)setProgress:(CGFloat)progress
{
    if (progress > 1) {
        progress = 1;
    }
    [self.progressView setFrame:CGRectMake(0, self.progressView.frame.origin.y, (self.frame.size.width*progress), self.progressView.frame.size.height)];
}

@end
